home *** CD-ROM | disk | FTP | other *** search
- /* strnset.c From TC Bible page 293 Use strnset to set a specified number
- of characters in a string, excluding the terminating null, to a specific
- character value */
-
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- main()
- {
- int c;
- size_t len;
- char buf[80];
- printf("Enter a string: ");
- gets(buf);
- printf("Enter character you want half the string set to: ");
- c = getche();
- len = strlen(buf)/2;
- strnset(buf, c, len); /* set first half of string to character in c */
- printf("\nString is now: %s\n", buf);
- }